/*** 本文件由CSMIS2.0-ModelCreater(UTF-8)工具辅助生成，版本1.0 ***/

package com.ce.sys.update.logic.search;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.ce.framework.datamaintain.logic.ISQLMapper;
import com.ce.framework.datamaintain.logic.SQLSearchCondition;
import com.ce.framework.exception.AppException;
import com.ce.framework.util.StringUtil;
import com.ce.sys.update.view.SysUpdateInfoView;

/**
* 嫦娥软件有限公司 版权所有 2013
* 创建人：　andy
* 创建日期：2010-11-08
* 创建时间：08:43:57
* 功能描述：系统更新信息表 [SYS_T_UPDATE$INFO]条件过滤类
* ==============================================
* 修改历史
* 修改人		修改时间		修改原因
*
* ==============================================
*/
public class SysUpdateInfoSearchCondition  extends SQLSearchCondition
	implements ISQLMapper
{

	/*
	 * 使用js框架分页时进行排序的必要属性
	 */
	private String order;   //排序方法
	private String sort;  //排序字段


	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}


	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public String getSearchSql() throws AppException {
		
		StringBuffer sql = new StringBuffer("select t.*,f.vc_filename,f.vc_user$name from SYS_T_UPDATE$INFO t,PUB_T_FILE_UPLOAD_LOG f where t.vc_file$id = f.vc_id(+)  and t.VC_DEL$FLAG = 0 " );
		//实现排序的代码
		if(StringUtil.isNotBlank(this.order)){
			if("dtUploadTime".equals(this.sort)){
				sql.append("  order by t.DT_UPLOAD$TIME "+this.order);
			}
			if("intUpdateFlag".equals(this.sort)){
				sql.append("  order by t.INT_UPDATE$FLAG "+this.order);
			}
			if("dtUpdateTime".equals(this.sort)){
				sql.append("  order by t.DT_UPDATE$TIME "+this.order);
			}
		}else{
			sql.append("  order by t.DT_UPLOAD$TIME desc ");
		}
		return sql.toString();
	}
	
	public Object fromSQLQuery(ResultSet rs, int num) {
		SysUpdateInfoView view = new SysUpdateInfoView();
		try {

			view.setVcId(rs.getString("VC_ID"));
			view.setDtUploadTime(rs.getTimestamp("DT_UPLOAD$TIME"));
			view.setVcFileId(rs.getString("VC_FILE$ID"));
			view.setVcUpdateDesc(rs.getString("VC_UPDATE$DESC"));
			view.setIntUpdateFlag(rs.getInt("INT_UPDATE$FLAG"));
			view.setDtUpdateTime(rs.getTimestamp("DT_UPDATE$TIME"));
			view.setVcDelFlag(rs.getInt("VC_DEL$FLAG"));	
			view.setFileName(rs.getString("vc_filename"));
			view.setUserName(rs.getString("vc_user$name"));

		} catch (SQLException e) {
			
			e.printStackTrace();
		}
		return view;
	}
	
	public ISQLMapper getSQLMapper() {
		
		return this;
	}

}

